package com.zhuss.advice.proposal;

import com.zhuss.advice.processor.ProposalRead;
import com.zhuss.bean.bo.advice.Complaint.SearchComplaintBo;
import com.zhuss.bean.bo.advice.Complaint.weChat.DetailComplaintWeChatBo;
import com.zhuss.bean.bo.advice.Complaint.weChat.SearchComplaintWeChatBo;
import com.zhuss.bean.bo.advice.proposal.DetailProposalBo;
import com.zhuss.bean.bo.advice.proposal.SearchProposalBo;
import com.zhuss.bean.bo.advice.proposal.weChat.DetailProposalWeChatBo;
import com.zhuss.bean.bo.advice.proposal.weChat.SearchProposalWeChatBo;
import com.zhuss.common.ReadService;
import com.zhuss.exception.WpsException;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

/**
 * @Author: zhushanshuo
 * @Date: 2020/3/6 9:27
 */
@Component("proposalReadService")
public class ProposalReadService implements ReadService<Object, Object> {

    @Autowired
    @Qualifier("proposalRead")
    private ProposalRead proposalRead;

    @Override
    public Object detail(Object o) throws WpsException {
        DetailProposalBo bo = (DetailProposalBo) o;
        Object result = proposalRead.detail(bo.getProposalId());
        return result;
    }

    @Override
    public Object list(Object o) throws WpsException {
        SearchProposalBo bo = (SearchProposalBo) o;
        Object result = proposalRead.list(bo);
        return result;
    }

    /**
     * 意见回复列表
     * @param o
     * @return
     * @throws WpsException
     */
    public Object replyList(Object o) throws WpsException {
        SearchProposalBo bo = (SearchProposalBo) o;
        Object result = proposalRead.list(bo);
        return result;
    }

    /**
     * 微信个人列表
     * @throws WpsException
     */
    public Object weChatList(Object o) throws WpsException {
        SearchProposalWeChatBo bo = (SearchProposalWeChatBo) o;
        bo.setCreateId(bo.getConcurrentUserId());
        bo.setArea(bo.getConcurrentArea());
        SearchProposalBo spBo = new SearchProposalBo();
        BeanUtils.copyProperties(bo,spBo);
        Object result = proposalRead.list(spBo);
        return result;
    }

    /**
     * 微信详情
     * @throws WpsException
     */
    public Object weChatDetail(Object o) throws WpsException {
        DetailProposalWeChatBo bo = (DetailProposalWeChatBo) o;
        Object result = proposalRead.detail(bo.getProposalId());
        return result;
    }
}
